<?php
/*
	插件概览
*/
defined('BY_JYA') or exit('error');
$_RQ['op']=$_RQ['op']?$_RQ['op']:'get';
$plugin_name = $_RQ['basicname'] ? $_RQ['basicname'] : '';
if($_RQ['op']=='get'){
	//显示统计数据
		$daytime = mktime(0,0,0,date('m'),date('d'),date('Y'));
		$mounthtime =  mktime(0,0,0,date('m'),1,date('Y'));
		$access=array();
		$access['all_day']=pdo_count('jy_qqdian_sharer_order',array('uniacid'=>$_SESSION['uniacid'],'createtime >'=>$daytime));
		$access['all_all']=pdo_count('jy_qqdian_sharer_order',array('uniacid'=>$_SESSION['uniacid']));
		
		foreach($this->share_scene as $k=>$sv){
			$access['day'.$k]=pdo_count('jy_qqdian_sharer_order',array('uniacid'=>$_SESSION['uniacid'],'share_scene'=>$k,'createtime >'=>$daytime));
			$access['all'.$k]=pdo_count('jy_qqdian_sharer_order',array('uniacid'=>$_SESSION['uniacid'],'share_scene'=>$k));
			$access['allfee'.$k]=pdo_getsum('jy_qqdian_sharer_order',array('uniacid'=>$_SESSION['uniacid'],'share_scene'=>$k),'price');
		}
		//月份
		for($i=0;$i<12;$i++){
				if($i==0){
					$yuestart = mktime(0,0,0,date('m'),1,date('Y'));
					$yueend = time();
					
				}else{
					$yuestart = mktime(0,0,0,date('m')-$i,1,date('Y'));
					$yueend = mktime(0,0,0,date('m')-$i+1,1,date('Y'));
				}
				$params=array('uniacid'=>$_SESSION['uniacid']);
				$params['createtime between']=array($yuestart,$yueend);
				$month12[$i] = date('Y-m',strtotime('-'.$i.' month'));
				//$monthaccess[]=pdo_count('core_access_log',$params);
				$accessline[$i]=pdo_count('jy_qqdian_sharer_order',$params);
				//$monthcredit2[]=pdo_getsum('core_members',$params,'credit2');
		}
		$accessline=array_reverse($accessline);
		$month12=array_reverse($month12);
	$datas=array();
	$dannumdatas=array();
	$danfeedatas=array();
	foreach($this->share_scene as $k=>$sv){
		$datas[]=array('title'=>$sv,'num'=>2,'data'=>array($access['day'.$k],$access['all'.$k]));
		$dannumdatas[]=array(
			'name'=>$sv,
			'value'=>$access['all'.$k]
		);
		$danfeedatas[]=array(
			'name'=>$sv,
			'value'=>$access['allfee'.$k]
		);
	}
	$datas[]=array('title'=>'总访问量','num'=>2,'data'=>array($access['all_day'],$access['all_all']));
	$return['htmls']=array(
		array('type'=>'data','one_num'=>2,'title'=>'应用今日/总分享下单数据指标','datas'=>$datas),
		
		array('type'=>'echarts_pie','one_num'=>2,'width'=>'50%','ecid'=>'wechat','title'=>'分享订单量分布图','datas'=>array(
				'time' => date("Y-m-d H:i:s", time()),
				'datas'=>$dannumdatas,
		)),
		array('type'=>'echarts_pie','one_num'=>2,'width'=>'50%','ecid'=>'wxapp','title'=>'分享订单额分布图','datas'=>array(
				'time' => date("Y-m-d H:i:s", time()),
				'datas'=>$danfeedatas,
		)),
		array('type'=>'echarts_arealine','ecid'=>'mobile','title'=>'月度分享订单数据','datas'=>array(
					'datas'=>array(
						array('name'=>'分享订单','value'=>$accessline),
					),
					'xdatas'=>$month12,
		)),
	);
	exi($return);
}